package com.baizhi.abstractx2;

import java.util.Scanner;

import static java.lang.System.out;

public class Trapezoid extends Shape{
    private double top;
    private double bottom;
    private double left;
    private double right;
    private double height;



    @Override
    public double area() {
        return (top + bottom) * height/2;
    }

    @Override
    public double perimeter() {
        return top + bottom + left + right;
    }

    @Override
    public void inInfo(Scanner scan) {
        out.println("请输入梯形的底边");
        bottom = scan.nextDouble();
        out.println("请输入梯形的高：");
        height = scan.nextDouble();
        out.println("请输入梯形的上边：");
        top = scan.nextDouble();
        out.println("请输入梯形左边腰长：");
        right = scan.nextDouble();
        out.println("请输入梯形右边边腰长：");
        right = scan.nextDouble();

        //打印图形的面积和周长
        out.println("您输入的长方形的面积是：" + area());
        out.println("您输入的长方形的周长是：" + perimeter());
    }
}
